// 方法
function thatDae(str) {
  let reslut = dayjs(str, "MMDD").valueOf();
  let thatdate = dayjs(reslut).format("MM-DD");
  return thatdate;
}
function thatDaey(str) {
  let reslut = dayjs(str, "YYYYMM").valueOf();
  let thatdate = dayjs(reslut).format("YYYY-MM");
  return thatdate;
}
function thatDaeM(str) {
  let reslut = dayjs(str, "YYYYMM").valueOf();
  let thatdate = dayjs(reslut).format("MM");
  return thatdate;
}
//施工兑现率图表
$.ajax({
  type: "get",
  async: true, //异步执行
  url: base_url + "/cshRate",
  dataType: "json", //返回数据形式为json
  success: function (data) {
    if (data.code == 1000) {
      cshRateData = data.data;
      if (Object.keys(cshRateData).length !== 0) {
        $(".cashingRate_max").text((cshRateData.max * 100).toFixed(2) + "%");
        if (cshRateData.length !== 0) {
          majorSet = cshRateData.majorSet;
          mthSet = cshRateData.mthSet.map((v) => thatDaey(v));
          resv_data = cshRateData.resv_data.map((v) => (v * 100).toFixed(2));
          trk_data = cshRateData.trk_data.map((v) => (v * 100).toFixed(2));
          statn_data = cshRateData.statn_data.map((v) => (v * 100).toFixed(2));
          pak_data = cshRateData.pak_data.map((v) => (v * 100).toFixed(2));
          cashingRateEchart();
        } else {
          $("#cashingRateEchart").html(
            "<div class='noData'>今日暂无数据</div>"
          );
        }
        if (data.data.max == 0) {
          data.data = [];
        }
      }
    } else {
      alert(data.message);
    }
  },
  error: function (errorMsg) {
    console.log("请求数据失败");
  },
});

// 施工计划工时利用率;
$.ajax({
  type: "get",
  async: true, //异步执行
  url: base_url + "/utznRate",
  dataType: "json", //返回数据形式为json
  success: function (data) {
    if (data.code == 1000) {
      if (Object.keys(data.data).length !== 0) {
        $(".utilizationRate_max").text((data.data.max * 100).toFixed(2) + "%");
        majorSetU = data.data.majorSet;
        if (majorSetU.length !== 0) {
          mthSetU = data.data.mthSet.map((v) => thatDaey(v));
          resv_dataU = data.data.resv_data.map((v) => (v * 100).toFixed(2));
          trk_dataU = data.data.trk_data.map((v) => (v * 100).toFixed(2));
          statn_dataU = data.data.statn_data.map((v) => (v * 100).toFixed(2));
          pak_dataU = data.data.pak_data.map((v) => (v * 100).toFixed(2));
          utilizationRateEchart();
        } else {
          $("#utilizationRateEchart").html(
            "<div class='noData'>今日暂无数据</div>"
          );
        }
        if (data.data.max == 0) {
          data.data = [];
        }
      }
    } else {
      alert(data.message);
    }
  },
  error: function (errorMsg) {
    console.log("请求数据失败");
  },
});
// 施工变更率;
$.ajax({
  type: "get",
  async: true, //异步执行
  url: base_url + "/chgRate",
  dataType: "json", //返回数据形式为json
  success: function (data) {
    if (data.code == 1000) {
      if (Object.keys(data.data).length !== 0) {
        $(".changeRate_max").text((data.data.max * 100).toFixed(2) + "%");
        majorSetC = data.data.majorSet;
        if (majorSetC.length !== 0) {
          mthSetC = data.data.mthSet.map((v) => thatDaey(v));
          resv_dataC = data.data.resv_data.map((v) => (v * 100).toFixed(2));
          trk_dataC = data.data.trk_data.map((v) => (v * 100).toFixed(2));
          statn_dataC = data.data.statn_data.map((v) => (v * 100).toFixed(2));
          pak_dataC = data.data.pak_data.map((v) => (v * 100).toFixed(2));
          changeRateEchart();
        } else {
          $("#changeRateEchart").html("<div class='noData'>今日暂无数据</div>");
        }

        if (data.data.max == 0) {
          data.data = [];
        }
      } else {
        $("#changeRateEchart").html("<div class='noData'>今日暂无数据</div>");
      }
    } else {
      alert(data.message);
    }
  },
  error: function (errorMsg) {
    console.log("请求数据失败");
  },
});
//施工规范率
$.ajax({
  type: "get",
  async: true, //异步执行
  url: base_url + "/stdRate",
  dataType: "json", //返回数据形式为json
  success: function (data) {
    if (data.code == 1000) {
      if (data.data !== null) {
        stdRateData = data.data;
        if (Object.keys(stdRateData).length !== 0) {
          $(".standardRate_max").text((stdRateData.max * 100).toFixed(2) + "%");
          standardRateEchart();
        } else {
          $("#standardRateEchart").html(
            "<div class='noData'>今日暂无数据</div>"
          );
        }
      } else {
        $("#standardRateEchart").html("<div class='noData'>今日暂无数据</div>");
      }
    } else {
      alert(data.message);
    }
  },
  error: function (errorMsg) {
    console.log("请求数据失败");
  },
});
//线路车辆数(列)
$.ajax({
  type: "get",
  async: true, //异步执行
  url: base_url + "/lnVehNr",
  dataType: "json", //返回数据形式为json
  success: function (data) {
    if (data.code == 1000) {
      if (data.data !== null) {
        lineVehiclesNumData = data.data.datas;
        if (Object.keys(data.data).length !== 0) {
          $(".vehiclesNumberColumn_num").text(805);
          if (lineVehiclesNumData.length !== 0) {
            lineVehiclesNumlnNm = lineVehiclesNumData.map((v) => v.lnNm);
            lineVehiclesNumlnOnLnVehNr = lineVehiclesNumData.map(
              (v) => v.lnOnLnVehNr
            );
            lineVehiclesNumlnAvlVehNr = lineVehiclesNumData.map(
              (v) => v.lnAvlVehNr
            );
            lineVehiclesNumlnAtchVehNr = lineVehiclesNumData.map(
              (v) => v.lnAtchVehNr
            );
            vehiclesNumberColumnEchart();
          } else {
            $(".vehiclesNumberColumnEchart").html(
              "<div class='noData'>今日暂无数据</div>"
            );
          }
        } else {
          $(".vehiclesNumberColumnEchart").html(
            "<div class='noData'>今日暂无数据</div>"
          );
        }
      } else {
        $(".numLineVehicles_chart").html(
          "<div class='noData'>今日暂无数据</div>"
        );
      }
    } else {
      alert(data.message);
    }
  },
  error: function (errorMsg) {
    console.log("请求数据失败");
  },
});

//线路车辆数(辆)
$.ajax({
  type: "get",
  async: true, //异步执行
  url: base_url + "/lnVehUntNr",
  dataType: "json", //返回数据形式为json
  success: function (data) {
    if (data.code == 1000) {
      if (data.data !== null) {
        numLineVehiclesData = data.data.datas;
        if (Object.keys(data.data).length !== 0) {
          $(".vehiclesNumberVehicle_num").text(4859);
          if (numLineVehiclesData.length !== 0) {
            numLineVehicleslnNm = numLineVehiclesData.map((v) => v.lnNm);
            numLineVehicleslnOnLnVehNr = numLineVehiclesData.map(
              (v) => v.lnOnLnVehUntNr
            );
            numLineVehicleslnAvlVehNr = numLineVehiclesData.map(
              (v) => v.lnAvlVehUntNr
            );
            numLineVehicleslnAtchVehNr = numLineVehiclesData.map(
              (v) => v.lnAtchVehUntNr
            );
            vehiclesNumberVehicleEchart();
          } else {
            $(".vehiclesNumberVehicleEchart").html(
              "<div class='noData'>今日暂无数据</div>"
            );
          }
        } else {
          $(".vehiclesNumberVehicleEchart").html(
            "<div class='noData'>今日暂无数据</div>"
          );
        }
      } else {
        $(".vehiclesNumberVehicleEchart").html(
          "<div class='noData'>今日暂无数据</div>"
        );
      }
    } else {
      alert(data.message);
    }
  },
  error: function (errorMsg) {
    console.log("请求数据失败");
  },
});

// 施工兑现率
function cashingRateEchart() {
  let cashingRateE = document.getElementsByClassName("cashingRateEchart");
  for (var i = 0; i < cashingRateE.length; i++) {
    let myChartCashingRate = echarts.init(cashingRateE[i]);
    var colors = ["#0894EF", "#FFCB15", "#32E8BF", "#F43D3D"],
      option = {
        color: colors,
        tooltip: {
          trigger: "axis",
          formatter: function (params) {
            var res = params[0].name;
            for (let i = 0; i < params.length; i++) {
              const element = params[i];
              res +=
                "<br/><div style='width: 10px;height: 10px;border-radius: 50%;background: " +
                colors[i] +
                ";display: inline-block'></div> " +
                element.seriesName +
                ": " +
                element.value +
                "%";
            }
            return res;
          },
        },
        legend: {
          data: majorSet,
          top: "0",
          textStyle: {
            color: "#fff",
            fontSize: 14,
          },
        },
        grid: {
          top: "8%",
          left: "3%",
          right: "4%",
          bottom: "5%",
          containLabel: true,
        },
        yAxis: [
          {
            name: "",
            type: "value",
            max: 100, //设置最大值
            min: 0, //最小值
            splitNumber: 11, //11个刻度线，也就是10等分
            axisLabel: {
              show: true,
              interval: "auto",
              formatter: "{value}.00 %",
              color: "#A2D4E6",
              fontSize: 14,
            },
            show: true,
            axisLine: { show: false },
            splitLine: {
              lineStyle: {
                // type: "dashed",
                color: "#657CA8",
                opacity: 0.1,
              },
            },
            axisTick: {
              show: false,
            },
          },
        ],
        xAxis: [
          {
            type: "category",
            data: mthSet,
            axisLabel: {
              color: "#A2D4E6",
              fontSize: 14,
              margin: 15,
              //   rotate: 45,
            },
            axisLine: {
              lineStyle: {
                // type: "dashed",
                color: "#657CA8",
                opacity: 0.1,
              },
            },
            axisTick: {
              show: false,
            },
          },
        ],
        series: [
          {
            name: majorSet[0],
            symbol: "circle",
            type: "line",
            barWidth: "20px",
            data: statn_data,
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(8,148,239,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(8,148,239,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(8,148,239, 0.9)",
                shadowBlur: 20,
              },
            },
          },
          {
            name: majorSet[1],
            symbol: "circle",
            type: "line",
            barWidth: "20px",
            data: resv_data,
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(255,203,21,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(255,203,21,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(255,203,21, 0.9)",
                shadowBlur: 20,
              },
            },
          },
          {
            name: majorSet[2],
            symbol: "circle",
            type: "line",
            barWidth: "20px",
            data: pak_data,
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(50,243,191,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(50,243,191,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(50,243,191, 0.9)",
                shadowBlur: 20,
              },
            },
          },
          {
            name: majorSet[3],
            symbol: "circle",
            type: "line",
            barWidth: "20px",
            data: trk_data,
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(244,61,61,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(244,61,61,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(244,61,61, 0.9)",
                shadowBlur: 20,
              },
            },
          },
        ],
      };
    // 使用刚指定的配置项和数据显示图表。
    myChartCashingRate.setOption(option);
    window.addEventListener("resize", function () {
      myChartCashingRate.resize();
    });
  }
}
// 施工计划工时利用率
function utilizationRateEchart() {
  let utilizationRateE = document.getElementsByClassName(
    "utilizationRateEchart"
  );
  for (var i = 0; i < utilizationRateE.length; i++) {
    let myChartutilizationRate = echarts.init(utilizationRateE[i]);
    var colors = ["#0894EF", "#FFCB15", "#32E8BF", "#F43D3D"],
      option = {
        color: colors,
        tooltip: {
          trigger: "axis",
          formatter: function (params) {
            var res = params[0].name;
            for (let i = 0; i < params.length; i++) {
              const element = params[i];
              res +=
                "<br/><div style='width: 10px;height: 10px;border-radius: 50%;background: " +
                colors[i] +
                ";display: inline-block'></div> " +
                element.seriesName +
                ": " +
                element.value +
                "%";
            }
            return res;
          },
        },
        legend: {
          data: majorSetU,
          top: "0",
          textStyle: {
            color: "#fff",
            fontSize: 14,
          },
        },
        grid: {
          top: "8%",
          left: "3%",
          right: "4%",
          bottom: "5%",
          containLabel: true,
        },
        yAxis: [
          {
            name: "",
            type: "value",
            max: 100, //设置最大值
            min: 0, //最小值
            splitNumber: 11, //11个刻度线，也就是10等分
            axisLabel: {
              show: true,
              interval: "auto",
              formatter: "{value}.00 %",
              color: "#A2D4E6",
              fontSize: 14,
            },
            show: true,
            axisLine: { show: false },
            splitLine: {
              lineStyle: {
                // type: "dashed",
                color: "#657CA8",
                opacity: 0.1,
              },
            },
            axisTick: {
              show: false,
            },
          },
        ],
        xAxis: [
          {
            type: "category",
            data: mthSetU,
            axisLabel: {
              color: "#A2D4E6",
              fontSize: 14,
              margin: 15,
            },
            axisLine: {
              lineStyle: {
                color: "#657CA8",
                opacity: 0.1,
              },
            },
            axisTick: {
              show: false,
            },
          },
        ],
        series: [
          {
            name: majorSetU[0],
            symbol: "circle",
            type: "line",
            barWidth: "20px",
            data: statn_dataU,
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(8,148,239,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(8,148,239,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(8,148,239, 0.9)",
                shadowBlur: 20,
              },
            },
          },
          {
            name: majorSetU[1],
            symbol: "circle",
            type: "line",
            barWidth: "20px",
            data: resv_dataU,
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(255,203,21,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(255,203,21,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(255,203,21, 0.9)",
                shadowBlur: 20,
              },
            },
          },
          {
            name: majorSetU[2],
            symbol: "circle",
            type: "line",
            barWidth: "20px",
            data: pak_dataU,
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(50,243,191,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(50,243,191,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(50,243,191, 0.9)",
                shadowBlur: 20,
              },
            },
          },
          {
            name: majorSetU[3],
            symbol: "circle",
            type: "line",
            barWidth: "20px",
            data: trk_dataU,
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(244,61,61,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(244,61,61,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(244,61,61, 0.9)",
                shadowBlur: 20,
              },
            },
          },
        ],
      };
    // 使用刚指定的配置项和数据显示图表。
    myChartutilizationRate.setOption(option);
    window.addEventListener("resize", function () {
      myChartutilizationRate.resize();
    });
  }
}
// 施工变更率图表
function changeRateEchart() {
  let shigongCC = document.getElementsByClassName("changeRateEchart");
  for (var i = 0; i < shigongCC.length; i++) {
    let myChartchangeRate = echarts.init(shigongCC[i]);
    var colors = ["#0894EF", "#FFCB15", "#32E8BF", "#F43D3D"],
      option = {
        color: colors,
        tooltip: {
          trigger: "axis",
          formatter: function (params) {
            var res = params[0].name;
            for (let i = 0; i < params.length; i++) {
              const element = params[i];
              res +=
                "<br/><div style='width: 10px;height: 10px;border-radius: 50%;background: " +
                colors[i] +
                ";display: inline-block'></div> " +
                element.seriesName +
                ": " +
                element.value +
                "%";
            }
            return res;
          },
        },
        legend: {
          data: majorSetC,
          top: "0",
          textStyle: {
            color: "#fff",
            fontSize: 14,
          },
        },
        grid: {
          top: "8%",
          left: "3%",
          right: "4%",
          bottom: "5%",
          containLabel: true,
        },
        yAxis: [
          {
            name: "",
            type: "value",
            max: 4, //设置最大值
            min: 0, //最小值
            // splitNumber: 10,
            // boundaryGap:[0,1],
            axisLabel: {
              show: true,
              interval: "auto",
              formatter: "{value}%",
              color: "#A2D4E6",
              fontSize: 14,
            },
            // show: true,
            axisLine: { show: false },
            splitLine: {
              lineStyle: {
                // type: "dashed",
                color: "#657CA8",
                opacity: 0.1,
              },
            },
            axisTick: {
              show: false,
            },
          },
        ],
        xAxis: [
          {
            type: "category",
            data: mthSetC,
            axisLabel: {
              color: "#A2D4E6",
              fontSize: 14,
              margin: 15,
            },
            axisTick: {
              show: false,
            },
            axisLine: {
              lineStyle: {
                // type: "dashed",
                color: "#657CA8",
                opacity: 0.1,
              },
            },
          },
        ],
        series: [
          {
            name: majorSetC[0],
            symbol: "circle",
            type: "line",
            barWidth: "20px",
            data: resv_dataC,
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(8,148,239,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(8,148,239,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(8,148,239, 0.9)",
                shadowBlur: 20,
              },
            },
          },
          {
            name: majorSetC[1],
            symbol: "circle",
            type: "line",
            barWidth: "20px",
            data: pak_dataC,
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(8,148,239,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(8,148,239,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(8,148,239, 0.9)",
                shadowBlur: 20,
              },
            },
          },
          {
            name: majorSetC[2],
            symbol: "circle",
            type: "line",
            barWidth: "20px",
            data: statn_dataC,
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(50,243,191,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(50,243,191,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(50,243,191, 0.9)",
                shadowBlur: 20,
              },
            },
          },
          {
            name: majorSetC[3],
            symbol: "circle",
            type: "line",
            barWidth: "20px",
            data: trk_dataC,
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(244,61,61,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(244,61,61,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(244,61,61, 0.9)",
                shadowBlur: 20,
              },
            },
          },
        ],
      };
    // 使用刚指定的配置项和数据显示图表。
    myChartchangeRate.setOption(option);
    window.addEventListener("resize", function () {
      myChartchangeRate.resize();
    });
  }
}
//施工规范率
function standardRateEchart() {
  let constructionStandardC = document.getElementsByClassName(
    "standardRateEchart"
  );
  for (var i = 0; i < constructionStandardC.length; i++) {
    let myChart = echarts.init(constructionStandardC[i]);
    // 颜色设置
    var color = {
      linearYtoG: {
        type: "linear",
        x: 0,
        y: 0,
        x2: 1,
        y2: 1,
        colorStops: [
          {
            offset: 0,
            color: "#f5b44d",
          },
          {
            offset: 1,
            color: "#28f8de",
          },
        ],
      },
      linearGtoB: {
        type: "linear",
        x: 0,
        y: 0,
        x2: 1,
        y2: 0,
        colorStops: [
          {
            offset: 0,
            color: "#43dfa2",
          },
          {
            offset: 1,
            color: "#28f8de",
          },
        ],
      },
      linearBtoG: {
        type: "linear",
        x: 0,
        y: 0,
        x2: 1,
        y2: 0,
        colorStops: [
          {
            offset: 0,
            color: "#1c98e8",
          },
          {
            offset: 1,
            color: "#28f8de",
          },
        ],
      },
      areaBtoG: {
        type: "linear",
        x: 0,
        y: 0,
        x2: 0,
        y2: 1,
        colorStops: [
          {
            offset: 0,
            color: "rgba(35,184,210,.2)",
          },
          {
            offset: 1,
            color: "rgba(35,184,210,0)",
          },
        ],
      },
    };
    var colors = ["#0894EF", "#FFCB15", "#32E8BF", "#F43D3D"],
      option = {
        color: colors,
        title: {
          text: thatDaeM(stdRateData.indiviData.mth) + "月施工规范率",
          right: "20%",
          bottom: "5%",
          textStyle: {
            color: "#fff",
            fontSize: 14,
          },
        },
        tooltip: {
          trigger: "item",
        },
        legend: {
          data: stdRateData.majorSet,
          top: "0",
          textStyle: {
            color: "#fff",
            fontSize: 14,
          },
        },
        radar: {
          center: ["70%", "50%"],
          radius: "45%",
          name: {
            color: "#fff",
          },
          splitNumber: 8,
          axisLine: {
            lineStyle: {
              color: color.linearYtoG,
              opacity: 0.6,
            },
          },
          indicator: [
            {
              name:
                stdRateData.majorSet[0] +
                "\n" +
                (stdRateData.indiviData.dataList[0] * 100).toFixed(2) +
                "%",
              max: 200,
            },
            {
              name:
                stdRateData.majorSet[1] +
                "\n" +
                (stdRateData.indiviData.dataList[1] * 100).toFixed(2) +
                "%",
              max: 200,
            },
            {
              name:
                stdRateData.majorSet[2] +
                "\n" +
                (stdRateData.indiviData.dataList[2] * 100).toFixed(2) +
                "%",
              max: 200,
            },
            {
              name:
                stdRateData.majorSet[3] +
                "\n" +
                (stdRateData.indiviData.dataList[3] * 100).toFixed(2) +
                "%",
              max: 200,
            },
          ],
        },
        grid: {
          top: "10%",
          left: "3%",
          right: "62%",
          bottom: "5%",
          containLabel: true,
        },
        xAxis: {
          type: "category",
          boundaryGap: false,
          axisLabel: {
            color: "#A2D4E6",
            fontSize: 14,
            margin: 15,
          },
          axisTick: {
            show: false,
          },
          axisLine: {
            lineStyle: {
              // type: "dashed",
              color: "#657CA8",
              opacity: 0.1,
            },
          },
          data: stdRateData.mthSet.map((v) => thatDaeM(v) + "月"),
        },
        yAxis: {
          type: "value",
          scale: true,
          axisLabel: {
            formatter: "{value}%",
            color: "#A2D4E6",
            fontSize: 14,
          },
          axisLine: { show: false },
          splitLine: {
            lineStyle: {
              // type: "dashed",
              color: "#657CA8",
              opacity: 0.1,
            },
          },
          axisTick: {
            show: false,
          },
        },
        series: [
          {
            name: thatDaeM(stdRateData.indiviData.mth) + "月施工规范率",
            type: "radar",
            symbolSize: 0,
            data: [
              {
                value: stdRateData.indiviData.dataList.map((v) =>
                  (v * 100).toFixed(2)
                ),
                itemStyle: {
                  normal: {
                    color: "#f8d351",
                  },
                },
                lineStyle: {
                  normal: {
                    opacity: 0,
                  },
                },
                areaStyle: {
                  normal: {
                    color: "#f8d351",
                    shadowBlur: 25,
                    shadowColor: "rgba(248,211,81,.3)",
                    shadowOffsetX: 0,
                    shadowOffsetY: -10,
                    opacity: 1,
                  },
                },
              },
            ],
          },
          {
            name: stdRateData.majorSet[0],
            type: "line",
            symbol: "circle",
            barWidth: "50%",
            data: stdRateData.statn_data.map((v) => (v * 100).toFixed(2)),
            barWidth: "20px",
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(8,148,239,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(8,148,239,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(8,148,239, 0.9)",
                shadowBlur: 20,
              },
            },
          },
          {
            name: stdRateData.majorSet[1],
            type: "line",
            symbol: "circle",
            barWidth: "50%",
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(8,148,239,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(8,148,239,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(8,148,239, 0.9)",
                shadowBlur: 20,
              },
            },
            data: stdRateData.resv_data.map((v) => (v * 100).toFixed(2)),
          },
          {
            name: stdRateData.majorSet[2],
            type: "line",
            symbol: "circle",
            barWidth: "50%",
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(50,243,191,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(50,243,191,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(50,243,191, 0.9)",
                shadowBlur: 20,
              },
            },
            data: stdRateData.statn_data.map((v) => (v * 100).toFixed(2)),
          },
          {
            name: stdRateData.majorSet[3],
            type: "line",
            symbol: "circle",
            barWidth: "50%",
            lineStyle: {
              normal: {
                width: 1,
              },
            },
            areaStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(244,61,61,0.3)",
                    },
                    {
                      offset: 1,
                      color: "rgba(244,61,61,0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(244,61,61, 0.9)",
                shadowBlur: 20,
              },
            },
            data: stdRateData.trk_data.map((v) => (v * 100).toFixed(2)),
          },
        ],
      };
    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
    window.addEventListener("resize", function () {
      myChart.resize();
    });
  }
}
//线路车辆数(列)
function vehiclesNumberColumnEchart() {
  let vehiclesNumberColumnE = document.getElementsByClassName(
    "vehiclesNumberColumnEchart"
  );
  for (var i = 0; i < vehiclesNumberColumnE.length; i++) {
    let myChartvehiclesNumberColumn = echarts.init(vehiclesNumberColumnE[i]);
    var zoomstart = 0;
    var zoomend = 100;
    function restart() {
      option = {
        tooltip: {
          trigger: "axis",
          axisPointer: {
            // 坐标轴指示器，坐标轴触发有效
            type: "shadow", // 默认为直线，可选为：'line' | 'shadow'
          },
        },
        grid: {
          top: "18%",
          left: "3%",
          right: "4%",
          bottom: "5%",
          containLabel: true,
        },
        legend: {
          top: "0",
          textStyle: {
            color: "#fff",
            fontSize: 14,
          },
          data: ["上线车辆数", "可用车辆数", "配属车辆数"],
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: true,
            axisLine: {
              //坐标轴轴线相关设置。数学上的x轴
              show: false,
              lineStyle: {
                color: "#f9f9f9",
              },
            },
            axisLabel: {
              color: "#A2D4E6",
              fontSize: 14,
              margin: 15,
            },
            axisTick: {
              show: false,
            },
            data: lineVehiclesNumlnNm,
          },
        ],
        dataZoom: [
          {
            type: "slider",
            show: false,
            start: zoomStart(),
            end: zoomEnd(lineVehiclesNumlnNm.length), //默认显示条柱数
          },
        ],
        yAxis: [
          {
            name: "车辆数(列)",
            nameTextStyle: {
              //y轴上方单位的颜色
              color: "#A2D4E6",
              fontSize: 14,
            },
            type: "value",
            min: 0,
            splitNumber: 7,
            splitLine: {
              lineStyle: {
                // type: "dashed",
                color: "#657CA8",
                opacity: 0.1,
              },
            },
            axisLine: {
              show: false,
            },
            axisLabel: {
              // margin: 20,
              color: "#A2D4E6",
              fontSize: 14,
              formatter: function (value, index) {
                return value.toFixed(1);
              },
            },
            axisTick: {
              show: false,
            },
          },
        ],
        series: [
          {
            name: "上线车辆数",
            type: "bar",
            barWidth: 10,
            barGap: "0%",
            color: "#79A1B5",
            //   label: {
            //     show: true,
            //     position: "insideTop",
            //     textStyle: {
            //       color: "#F6F8FA",
            //     },
            //   },
            itemStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(1,130,222,1)", // 100% 处的颜色
                    },
                    {
                      offset: 1,
                      color: "rgba(63,40,208,1)", // 0% 处的颜色
                    },
                  ],
                  false
                ),
                barBorderRadius: [4, 4, 0, 0],
              },
            },
            data: lineVehiclesNumlnOnLnVehNr,
          },
          {
            name: "可用车辆数",
            type: "bar",
            barWidth: 10,
            color: "#F3EB00",
            itemStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(254,215,1,1)", // 100% 处的颜色
                    },
                    {
                      offset: 1,
                      color: "rgba(252,149,1,1)", // 0% 处的颜色
                    },
                  ],
                  false
                ),
                barBorderRadius: [4, 4, 0, 0],
              },
            },
            data: lineVehiclesNumlnAtchVehNr,
          },
          {
            name: "配属车辆数",
            type: "bar",
            barWidth: 10,
            color: "#F3EB00",
            itemStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(254,155,26,1)", // 100% 处的颜色
                    },
                    {
                      offset: 1,
                      color: "rgba(254,65,27,1)", // 0% 处的颜色
                    },
                  ],
                  false
                ),
                barBorderRadius: [4, 4, 0, 0],
              },
            },
            data: lineVehiclesNumlnAvlVehNr,
          },
        ],
      };
      // 使用刚指定的配置项和数据显示图表。
      myChartvehiclesNumberColumn.setOption(option);
      window.addEventListener("resize", function () {
        myChartvehiclesNumberColumn.resize();
      });
    }
    restart();
    setInterval(restart, 3000);

    //dataZoom的自动播放
    function zoomStart() {
      if (zoomend >= 100) zoomstart = 0;
      else {
        zoomstart += 7;
      }
      return zoomstart;
    }

    function zoomEnd(length) {
      var displayNum = screen.width > 1920 ? 12 : 6; //根据屏幕分辨率，定默认显示条柱数
      if (length > displayNum && zoomstart === 0) {
        zoomend = (displayNum / length) * 100;
      } else if (length > displayNum) {
        zoomend += 7;
      } else {
        zoomend = 100;
        clearInterval(restart);
      }
      return zoomend;
    }
  }
}
//线路车辆数
// numLineVehiclesChart();
function vehiclesNumberVehicleEchart() {
  let vehiclesNumberVehicleE = document.getElementsByClassName(
    "vehiclesNumberVehicleEchart"
  );
  for (var i = 0; i < vehiclesNumberVehicleE.length; i++) {
    let myChartvehiclesNumberVehicle = echarts.init(vehiclesNumberVehicleE[i]);
    var zoomstart = 0;
    var zoomend = 100;
    function restart() {
      option = {
        tooltip: {
          trigger: "axis",
          axisPointer: {
            // 坐标轴指示器，坐标轴触发有效
            type: "shadow", // 默认为直线，可选为：'line' | 'shadow'
          },
        },
        grid: {
          top: "18%",
          left: "3%",
          right: "4%",
          bottom: "5%",
          containLabel: true,
        },
        legend: {
          top: "0",
          textStyle: {
            color: "#fff",
            fontSize: 14,
          },
          data: ["上线车辆数", "可用车辆数", "配属车辆数"],
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: true,
            axisLine: {
              //坐标轴轴线相关设置。数学上的x轴
              show: false,
              lineStyle: {
                color: "#f9f9f9",
              },
            },
            axisLabel: {
              color: "#A2D4E6",
              fontSize: 14,
              margin: 15,
            },
            axisTick: {
              show: false,
            },
            data: numLineVehicleslnNm,
          },
        ],
        dataZoom: [
          {
            type: "slider",
            show: false,
            start: zoomStart(),
            end: zoomEnd(numLineVehicleslnNm.length), //默认显示条柱数
          },
        ],
        yAxis: [
          {
            name: "车辆数(辆)",
            nameTextStyle: {
              //y轴上方单位的颜色
              color: "#A2D4E6",
              fontSize: 14,
            },
            type: "value",
            min: 0,
            splitNumber: 7,
            splitLine: {
              lineStyle: {
                // type: "dashed",
                color: "#657CA8",
                opacity: 0.1,
              },
            },
            axisLine: {
              show: false,
            },
            axisLabel: {
              // margin: 20,
              color: "#A2D4E6",
              fontSize: 14,
              formatter: function (value, index) {
                return value.toFixed(1);
              },
            },
            axisTick: {
              show: false,
            },
          },
        ],
        series: [
          {
            name: "上线车辆数",
            type: "bar",
            barWidth: 10,
            barGap: "0%",
            color: "#79A1B5",
            //   label: {
            //     show: true,
            //     position: "insideTop",
            //     textStyle: {
            //       color: "#F6F8FA",
            //     },
            //   },
            itemStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(1,130,222,1)", // 100% 处的颜色
                    },
                    {
                      offset: 1,
                      color: "rgba(63,40,208,1)", // 0% 处的颜色
                    },
                  ],
                  false
                ),
                barBorderRadius: [4, 4, 0, 0],
              },
            },
            data: numLineVehicleslnOnLnVehNr,
          },
          {
            name: "可用车辆数",
            type: "bar",
            barWidth: 10,
            color: "#F3EB00",
            itemStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(254,215,1,1)", // 100% 处的颜色
                    },
                    {
                      offset: 1,
                      color: "rgba(252,149,1,1)", // 0% 处的颜色
                    },
                  ],
                  false
                ),
                barBorderRadius: [4, 4, 0, 0],
              },
            },
            data: numLineVehicleslnAtchVehNr,
          },
          {
            name: "配属车辆数",
            type: "bar",
            barWidth: 10,
            color: "#F3EB00",
            itemStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(254,155,26,1)", // 100% 处的颜色
                    },
                    {
                      offset: 1,
                      color: "rgba(254,65,27,1)", // 0% 处的颜色
                    },
                  ],
                  false
                ),
                barBorderRadius: [4, 4, 0, 0],
              },
            },
            data: numLineVehicleslnAvlVehNr,
          },
        ],
      };

      // 使用刚指定的配置项和数据显示图表。
      myChartvehiclesNumberVehicle.setOption(option);
      window.addEventListener("resize", function () {
        myChartvehiclesNumberVehicle.resize();
      });
    }
    restart();
    setInterval(restart, 3000);
    //dataZoom的自动播放
    function zoomStart() {
      if (zoomend >= 100) zoomstart = 0;
      else {
        zoomstart += 7;
      }
      return zoomstart;
    }

    function zoomEnd(length) {
      var displayNum = screen.width > 1920 ? 12 : 6; //根据屏幕分辨率，定默认显示条柱数
      if (length > displayNum && zoomstart === 0) {
        zoomend = (displayNum / length) * 100;
      } else if (length > displayNum) {
        zoomend += 7;
      } else {
        zoomend = 100;
        clearInterval(restart);
      }
      return zoomend;
    }
  }
}
